/**
 * 
 */
package cream.alarm.model;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Weekday model. This is an Immutable Class.
 * 
 * @author Cream
 * @since 1.0 2012-01-20
 */
public class Weekday {

	private final Date date;
	private final boolean isWeekday;
	private final String type;
	private final String desc;

	public Weekday(Date date, boolean isWeekday, String type, String desc) {
		super();
		this.date = date;
		this.isWeekday = isWeekday;
		this.type = type;
		this.desc = desc;
	}

	public Weekday(String dateStr, String isWeekdayStr, String type, String desc)
			throws ParseException {
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		Date date = df.parse(dateStr);
		boolean isWeekday = Boolean.parseBoolean(isWeekdayStr);

		this.date = date;
		this.isWeekday = isWeekday;
		this.type = type;
		this.desc = desc;
	}

	/**
	 * 获取日期。
	 * 
	 * @return the date
	 */
	public Date getDate() {
		return date;
	}

	/**
	 * 判断是否为工作日
	 * 
	 * @return the isWeekday
	 */
	public boolean isWeekday() {
		return isWeekday;
	}

	/**
	 * 获取类别
	 * 
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * 获取描述
	 * 
	 * @return the desc
	 */
	public String getDesc() {
		return desc;
	}

	@Override
	public String toString() {
		return "Weekday [date=" + date + ", isWeekday=" + isWeekday + ", type="
				+ type + ", desc=" + desc + "]";
	}

}
